package com.pds.web.monitor.controller;

import com.pds.common.core.controller.BaseController;
import com.pds.common.core.domain.R;
import com.pds.web.monitor.domain.PdsMonitorTaskRange;
import com.pds.web.monitor.dto.TaskRangeDTO;
import com.pds.web.monitor.service.IPdsMonitorTaskRangeService;
import com.pds.web.monitor.vo.LargeCategoryVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/TaskRange")
public class PdsMonitorTaskRangeController extends BaseController {

    @Autowired
    private IPdsMonitorTaskRangeService pdsMonitorTaskRangeService;

    /**
     * 新增任务类别
     * @param taskRangeDTO
     * @return
     */
    @PostMapping("/add")
    public R<Integer> addTaskRange(@RequestBody TaskRangeDTO taskRangeDTO){
        return R.ok(pdsMonitorTaskRangeService.addTaskRange(taskRangeDTO));
    }

    /**
     * 删除任务类别
     * @param ids -- 主键
     * @return
     */
    @GetMapping("/delete")
    public R<Integer> deleteTaskRange(@RequestParam("ids") List<Long> ids){
        return R.ok(pdsMonitorTaskRangeService.deleteTaskRange(ids));
    }

    /**
     * 更新任务类别
     * @param taskRangeDTO
     * @return
     */
    @PostMapping("/update")
    public R<Integer> updateTaskRange(@RequestBody TaskRangeDTO taskRangeDTO){
        return R.ok(pdsMonitorTaskRangeService.updateTaskRange(taskRangeDTO));
    }

    /**
     * 查询任务类别
     * @param pdsMonitorTaskRange
     * @return
     */
    @GetMapping("/list")
    public R<List<LargeCategoryVO>> listTaskRange(PdsMonitorTaskRange pdsMonitorTaskRange){
        List<LargeCategoryVO> list = pdsMonitorTaskRangeService.selectList(pdsMonitorTaskRange);
        return R.ok(list);
    }

}
